package com.mofeng.myshop.config;

import com.mofeng.myshop.properties.EmailProperty;
import com.mofeng.myshop.until.EmailSender;
import com.mofeng.myshop.until.SnowflakeIdWorker;
import lombok.RequiredArgsConstructor;
import org.springframework.context.annotation.Bean;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.stereotype.Component;

@Component
public class BeanConfig {

    @Bean
    public SnowflakeIdWorker snowflakeIdWorker(){
        return new SnowflakeIdWorker(1,1);
    }

    @Bean
    public BCryptPasswordEncoder creatPasswordEncoder() {
        return new BCryptPasswordEncoder();
    }

    @Bean
    public EmailSender creatEmailSender(EmailProperty emailProperty) {
        String email = emailProperty.getEmail();
        String password = emailProperty.getPassword();
        String type = emailProperty.getType();
        return new EmailSender(email,password,type);
    }
}
